<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<%@ include file="/module/orderField.jsp"%>

<script type="text/javascript" src="${basePath}/js/jquery.Huploadify.js"></script>
<link href="${basePath}/css/Huploadify.css" rel="stylesheet">
	<style>
table label.error {
	margin-left: 5px;
	width: auto;
	display: inline;
	color: red;
}
</style>
<script>
	$(document)
			.ready(
					function() {
						var _form = $("#Form").validate();
						//返回
						$('#btnBack').click(function() {
							document.Form.action = "${basePath}/forumContributions/index";
							document.Form.submit();
					  });
						//返回
						$('#btnBack2').click(function() {
							document.Form.action = "${basePath}/forumContributions/index";
							document.Form.submit();
					  });
						//保存
						$("#btnSave").click(
							function() {
								if (_form.form()) {
										$("#btnSave").attr("disabled","disabled");
										document.Form.action = "${basePath}/forumContributions/modiftyContributions";
										document.Form.submit();
								}
							});
						//回复并确定
						$("#btnReply").click(
							function() {
								if (_form.form()) {
									 $("#msg").html("");
									 var replycomments=$("#replycomments").val();
									   if(replycomments==""){
										   $("#msg").html("反馈意见不能为空");
										   return false;
									   }else{
										$("#btnReply").attr("disabled","disabled");
										document.Form.action = "${basePath}/forumContributions/modiftyContributionsReply";
										document.Form.submit();
									   }
								}
							});
						
					});
</script>
	<script type="text/javascript">
		//图片上传
		var file_path = "prefix";
		var file_path_one = null;
		var fileMap = new Array();
		$(function() {
			var up = $('#uploadadd').Huploadify({
				auto : false,
				fileTypeExts : '*.*',
				multi : true,
				formData : {
					key : 123456,
					key2 : 'vvvv'
				},
				fileSizeLimit : 99999999999,
				showUploadedPercent : true,
				showUploadedSize : true,
				removeTimeout : 9999999,
				uploader : '${basePath}/forumContributions/source_upload',
				onUploadStart : function(file) {
					console.log(file.name + '开始上传');
				},
				onInit : function(obj) {
					console.log('初始化');
				},
				onUploadComplete : function(file, data) {

					var fi = $.parseJSON(data);
					//文件名称
					var filename = fi.fileUuidName;
					//生成后的文件名
					//  var sysFilepath = fi.sysfilepath;
					//文件路径
					// var filepath = fi.filepath;
					// file_path_one = filename + "," + filepath;
					// file_path = file_path+"|"+filepath;
					//up.filePath=file_path_one;
					//保存到集合
					fileMap[file.index] = new Array(filename);
				},
				onCancel : function(file) {
					console.log(file.name + '删除成功');
				},
				onClearQueue : function(queueItemCount) {
					console.log('有' + queueItemCount + '个文件被删除了');
				},
				onDestroy : function() {
					console.log('destroyed!');
				},
				onSelect : function(file) {
					console.log(file.name + '加入上传队列');
				},
				onQueueComplete : function(queueData) {
					console.log('队列中的文件全部上传完成', queueData);
				}
			});
		});

		//删除图片 
		function deletefile(id) {
			var url = "${basePath}/forumContributions/deleteContributionFile";
			$.ajax({
				type : "POST",
				url : url,
				dataType : "json",
				data : {
					filepath : id
				},
				success : function(data) {
					if (data.success == "0000") {
						layer.alert('删除数据成功', {
							icon : 6
						});
						var file_name = id.split(",")[0];

						$("#" + file_name + "_hr").parent().parent().remove();
					} else {
						alert("未写入数据库的文件没有删除！请联系管理员！");
					}
				}
			})
		}
		//已有的数据进行删除操作
		function deleteAttachmentFile(id) {
			var action = "${basePath}/forumContributions/deleteFileSource";
			layer.confirm("您是否删除当前选中数据信息", {
				icon : 3,
				title : '提示',
				skin : 'layer-ext-moon'
			}, function(index) {
				$.ajax({
					type : "POST",
					url : action,
					dataType : "json",
					data : {
						id : id
					},
					success : function(data) {
						if (data.success == "0000") {
							layer.alert('删除数据成功', {
								icon : 6
							});
							$("#" + id + "_hr").parent().parent()
									.remove();
						} else {
							layer.alert('未写入数据库的文件没有删除！请联系管理员！', {
								icon : 5
							});
						}
					}
				})
			}, function(index) {
				layer.close(index);
			});
		}
	</script>
</head>
<body onload="javascript:viewOrEdit();">
	<form action="#" name="Form" id="Form" method="post">
		<input type="hidden" name="tgid" id="tgid"
			value="${jkyContribution.tgid}" />
		<input type="hidden" id="replytype" name="replytype" value="2" />
		<div id="view">
			<table cellpadding="0" cellspacing="0" border="0"
				class="table-border" width="95%">
				<tr>
					<td class="table-header" colspan="4">行政论坛投稿</td>
				</tr>
				<tr>
					<td class="table-titleTD" style="width: 15%">投稿人：</td>
					<td class="table-contentTD" style="width: 35%"><span>${jkyContribution.creatorname}</span>
					</td>
					<td class="table-titleTD" style="width: 15%">投稿日期：</td>
					<td class="table-contentTD" style="width: 35%"><span><fmt:formatDate value="${jkyContribution.createtime}" pattern="yyyy-MM-dd hh:mm:ss" /> </span>
					</td>
				</tr>
				<tr>
					<td class="table-titleTD" style="width: 15%">主题：</td>
					<td class="table-contentTD" style="width: 35%" colspan="3">${jkyContribution.subject}</td>
				</tr>
				<tr>
					<td class="table-titleTD" style="width: 15%">备注：</td>
					<td class="table-contentTD" colspan="3"><textarea
							style="width: 90%; height: 80px;" disabled="disabled">${jkyContribution.remark}</textarea></td>
				</tr>
				<tr>
					<td class="table-titleTD" style="width: 15%">稿件：</td>
					<td colspan="3" class="table-contentTD">
						<table>
<!-- 							<tr> -->
<!-- 								<td colspan="2"> -->
<!-- 									<div id="uploadadd"></div> -->
<!-- 								</td> -->
<!-- 							</tr> -->
							<c:forEach items="${contributionAttList}" var="contributionAtt"
								varStatus="index">
								<tr>
									<td>[文件] ${contributionAtt.filename}</td>
									<td><a
										href="${basePath}/uploadFile?filename=${contributionAtt.filename}&filepath=${contributionAtt.filepath}&contentType=${contributionAtt.contenttype}">下载</a>
									</td>
								</tr>
							</c:forEach>
						</table>
					</td>
				</tr>
			</table>
		</div>
		<br/>
		<div id="edit" style="display: none;">
		<table cellpadding="0" cellspacing="0" border="0"
				class="table-border" width="95%">
				<tr>
					<td class="table-header" colspan="4">行政论坛投稿</td>
				</tr>
				<tr>
					<td class="table-titleTD" style="width: 15%">投稿人：</td>
					<td class="table-contentTD" style="width: 35%"><span>${jkyContribution.creatorname}</span>
					<input type="hidden" id="creatorid" name="creatorid" value="${jkyContribution.creatorid}" /><input type="hidden" id="creatorname" name="creatorname" value="${jkyContribution.creatorname}" /> 
					</td>
					<td class="table-titleTD" style="width: 15%">投稿日期：</td>
					<td class="table-contentTD" style="width: 35%"><span><fmt:formatDate
								value="${jkyContribution.createtime}"
								pattern="yyyy-MM-dd hh:mm:ss" /> </span>
					</td>
				</tr>
				<tr>
					<td class="table-titleTD" style="width: 15%">主题：</td>
					<td class="table-contentTD" style="width: 35%" colspan="3">	<input type="text" id="subject" name="subject"  placeholder="请输入主题"  autocomplete="off"  class="inputText"  value="${jkyContribution.subject}" style="width: 30%"/></td>
				</tr>
				<tr>
					<td class="table-titleTD" style="width: 15%">备注：</td>
					<td class="table-contentTD" colspan="3"><textarea id="remark" name="remark"
							style="width: 90%; height: 80px;" placeholder="请输入备注信息" >${jkyContribution.remark}</textarea></td>
				</tr>
				<tr>
					<td class="table-titleTD" style="width: 15%">稿件：</td>
					<td colspan="3" class="table-contentTD">
						<table>
							<tr>
								<td colspan="2">
									<div id="uploadadd"></div>
								</td>
							</tr>
							<c:forEach items="${contributionAttList}" var="contributionAtt"
								varStatus="index">
								<tr>
									<td>[文件] ${contributionAtt.filename}</td>
									<td><a
										href="${basePath}/uploadFile?filename=${contributionAtt.filename}&filepath=${contributionAtt.filepath}&contentType=${contributionAtt.contenttype}">下载</a>
									<c:if test="${isReply!=1}">
										<button id="${contributionAtt.fileid}_hr" type="button"
											onclick="deleteAttachmentFile('${contributionAtt.fileid}');">删除</button>
								    </c:if>
									</td>
								</tr>
							</c:forEach>
						</table>
					</td>
				</tr>
			</table>
		</div>
		<br />
		<div id="button-view">
			<table cellpadding="1" cellspacing="1" border="0" align="left">
				<tr>
					<kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"JKY_JKS_WDXJLTTG\")%>" key="modify">
					<td><input type="button" id="btnEdit" class="inputButton"
						style="text-align: center;" value="修改"
						onclick="javascript:gotoEditPage();" /></td>
					</kl:permission> 
					<td><input type="button" id="btnBack" class="inputButton"
						value="返回" style="text-align: center;" /></td>
				</tr>
			</table>
		</div>
		<div id="button-edit">
			<table cellpadding="1" cellspacing="1" border="0" align="left">
				<tr>
					<td><input type="button" id="btnSave" class="inputButton"
						style="text-align: center;" value="保存" autocomplete="off" /></td>
					<td><input type="button" id="cancelSave" class="inputButton"
						style="text-align: center;" value="取消" autocomplete="off"
						onclick="javascript:gotoViewPage();" /></td>
					<td><input type="button" id="btnBack2" autocomplete="off"
						class="inputButton" value="返回" style="text-align: center;" /></td>
				</tr>
			</table>
		</div>
		<br/>
		<table cellpadding="0" cellspacing="0" border="0" class="table-border"
			width="100%">
			<tr>
				<td class="table-header" colspan="2">反馈意见与回复</td>
			</tr>
			<c:if test="${isReply==1}">
			<tr>
			  <td class="table-titleTD" style="width: 12%">回复内容：</td>
			  <td class="table-contentTD" style="width: 54%" colspan="3"><textarea style="width: 90%; height: 80px;" name="replycomments" id="replycomments"></textarea><span id="msg" style="color: red;"></span></td>
			</tr>
			<tr>
			<td colspan="2">
			 <br/>
			 <table cellpadding="1" cellspacing="1" border="0" align="left">
				<tr>
					<td><input type="button" id="btnReply" class="inputButton"
						style="text-align: center;" value="确认并回复" autocomplete="off" /></td>
				</tr>
			</table>
			</td>
			</tr>
		  </c:if>
		  <tr>
		   <td colspan="2">
		    <br/>
		    <table  cellpadding="0" cellspacing="0" border="0" class="table-border"
			width="100%">
			<tr>
			  <td class="table-titleTD" style="text-align: left;">序号</td>
			  <td class="table-titleTD" style="text-align: left;">姓名</td>
			   <td class="table-titleTD" style="text-align: left;">时间</td>
			  <td class="table-titleTD" style="text-align: left;">内容</td>
			</tr>
			<c:forEach items="${contributionReplyList}" var="contributionReply" varStatus="status">
			<tr>
			 <td class="table-contentTD" style="text-align: left;">${status.index+1}</td>
			  <td class="table-contentTD" style="text-align: left;">${contributionReply.replyername}</td>
			  <td class="table-contentTD" style="text-align: left;"><fmt:formatDate value="${contributionReply.replytime}" pattern="yyyy-MM-dd HH:mm" /></td>
			  <td class="table-contentTD" style="text-align: left;">${contributionReply.replycomments}</td>
			</tr>
			</c:forEach>
			</table>
		   </td>
		  </tr>
		</table>
	</form>
</body>
</html>
